﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="Users.aspx.cs" Inherits="EXAM.Admin.Page_Admin.Users" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlacebody" runat="server">
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="txtUserName">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="lbErr" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Vista">
    </telerik:RadWindowManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script type="text/javascript">
        //the following code use radconfirm to mimic the blocking of the execution thread.
        //The approach has the following limitations:
        //1. It works inly for elements that have *click* method, e.g. links and buttons
        //2. It cannot be used in if(!confirm) checks
        window.blockConfirm = function (text, mozEvent, oWidth, oHeight, callerObj, oTitle)
        {
            var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually 
            //Cancel the event 
            ev.cancelBubble = true;
            ev.returnValue = false;
            if (ev.stopPropagation) ev.stopPropagation();
            if (ev.preventDefault) ev.preventDefault();

            //Determine who is the caller 
            var callerObj = ev.srcElement ? ev.srcElement : ev.target;

            //Call the original radconfirm and pass it all necessary parameters 
            if (callerObj)
            {
                //Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again. 
                var callBackFn = function (arg)
                {
                    if (arg)
                    {
                        callerObj["onclick"] = "";
                        if (callerObj.click) callerObj.click(); //Works fine every time in IE, but does not work for links in Moz 
                        else if (callerObj.tagName == "A") //We assume it is a link button! 
                        {
                            try
                            {
                                eval(callerObj.href)
                            }
                            catch (e) { }
                        }
                    }
                }

                radconfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);
            }
            return false;
        } 
        
        function OnDelete_Click()
        {
           return radconfirm('Do you want delete these records?', confirmCallBackFn, 330, 100, null,'Client RadConfirm');
        }
        function confirmCallBackFn(arg)
        {
//            
    //        radalert("<strong>radconfirm</strong> returned the following result: <h3 style='color: #ff0000;'>" + arg + "</h3>", null, null, "Result");
        }
        </script>

    </telerik:RadCodeBlock>
    <div>
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
            <tr>
                <td align="center" class="formTitle">
                    User manager
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lbErr" runat="server" ForeColor="Red"></asp:Label>
                    <table>
                        <tr>
                            <td>
                                User Name
                            </td>
                            <td>
                                <telerik:RadTextBox ID="txtUserName" runat="server" AutoPostBack="True" OnTextChanged="txtUserName_TextChanged">
                                </telerik:RadTextBox>
                                <telerik:RadTextBox ID="txtID" runat="server" Visible="False" Width="50px">
                                </telerik:RadTextBox>
                                <telerik:RadTextBox ID="txtIP" runat="server" Visible="False" Width="50px">
                                </telerik:RadTextBox>
                                <telerik:RadTextBox ID="txtPass" runat="server" Visible="False" Width="50px">
                                </telerik:RadTextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Email
                            </td>
                            <td>
                                <telerik:RadTextBox ID="txtEmail" runat="server" Width="200px">
                                </telerik:RadTextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Register Date
                            </td>
                            <td>
                                <telerik:RadDatePicker ID="dpRegDate" runat="server" MinDate="1900-01-01">
                                    <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x">
                                    </Calendar>
                                    <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                                    <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy">
                                    </DateInput>
                                </telerik:RadDatePicker>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                First Name
                            </td>
                            <td>
                                <telerik:RadTextBox ID="txtFirstName" runat="server" Width="200px">
                                </telerik:RadTextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Last Name
                            </td>
                            <td>
                                <telerik:RadTextBox ID="txtLastName" runat="server" Width="300px">
                                </telerik:RadTextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Birthday
                            </td>
                            <td>
                                <telerik:RadDatePicker ID="dpBirthday" runat="server" MinDate="1900-01-01">
                                    <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x">
                                    </Calendar>
                                    <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                                    <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy">
                                    </DateInput>
                                </telerik:RadDatePicker>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Birth Place
                            </td>
                            <td>
                                <telerik:RadTextBox ID="txtBirthplace" runat="server">
                                </telerik:RadTextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Comment
                            </td>
                            <td>
                                <telerik:RadTextBox ID="txtComment" runat="server" Width="500px">
                                </telerik:RadTextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Is Admin
                            </td>
                            <td>
                                <telerik:RadButton ID="ckbANAL_U9" runat="server" ToggleType="CheckBox" ButtonType="LinkButton"
                                    AutoPostBack="false">
                                    <ToggleStates>
                                        <telerik:RadButtonToggleState Text="Checked" PrimaryIconCssClass="rbToggleCheckboxChecked" />
                                        <telerik:RadButtonToggleState Text="UnChecked" PrimaryIconCssClass="rbToggleCheckbox" />
                                    </ToggleStates>
                                </telerik:RadButton>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Position
                            </td>
                            <td>
                                <telerik:RadComboBox ID="cboANAL_U0" runat="server" EnableLoadOnDemand="True" OnItemsRequested="cboANAL_ItemsRequested"
                                    Width="216px" EmptyMessage="Choose a Position">
                                </telerik:RadComboBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Department
                            </td>
                            <td>
                                <telerik:RadComboBox ID="cboANAL_U1" runat="server" EnableLoadOnDemand="True" OnItemsRequested="cboANAL_ItemsRequested"
                                    Width="216px" EmptyMessage="Choose a  Dep.">
                                </telerik:RadComboBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Product
                            </td>
                            <td>
                                <telerik:RadComboBox ID="cboANAL_Q0" runat="server" EnableLoadOnDemand="True" OnItemsRequested="cboANAL_ItemsRequested"
                                    Width="216px" EmptyMessage="Choose a Product">
                                </telerik:RadComboBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Contact to
                            </td>
                            <td>
                                <telerik:RadTextBox ID="txtANAL_U3" runat="server" Width="216px">
                                </telerik:RadTextBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Group
                            </td>
                            <td>
                                <telerik:RadComboBox ID="cboPOG" runat="server" EnableLoadOnDemand="True" Width="216px"
                                    EmptyMessage="Choose a Group">
                                </telerik:RadComboBox>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Is Use
                            </td>
                            <td>
                                <telerik:RadTextBox ID="txtANAL_U8" runat="server" MaxLength="1" Width="50px">
                                </telerik:RadTextBox>
                                (Y/N)
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                    <div style="margin: auto; width: 400px">
                        <telerik:RadButton ID="btnNew" runat="server" Text="Add New" SplitButtonCssClass=""
                            SplitButtonPosition="Right" OnClick="btnNew_Click" Width="100px">
                        </telerik:RadButton>
                        <telerik:RadButton ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click"
                            Width="100px">
                        </telerik:RadButton>
                        <telerik:RadButton ID="btnClientDelete" runat="server" Text="Delete" Width="100px"
                            OnClientClick="return blockConfirm('Are you sure you want to delete these records?', event, 330, 100,'','Custom title');"
                            OnClick="btnDelete_Click">
                        </telerik:RadButton>
                    </div>
                    <br />
                    <br />
                    <div>
                        <telerik:RadGrid ID="dgvList" runat="server" AutoGenerateColumns="False" GridLines="None"
                            Skin="Office2007" AllowFilteringByColumn="True" AllowMultiRowSelection="True"
                            AllowPaging="True" AllowSorting="True" OnItemCommand="dgvList_ItemCommand" ShowGroupPanel="True"
                            OnNeedDataSource="dgvList_NeedDataSource">
                            <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Office2007">
                            </HeaderContextMenu>
                            <MasterTableView PageSize="20" DataKeyNames="ID">
                                <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </RowIndicatorColumn>
                                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </ExpandCollapseColumn>
                                <Columns>
                                    <telerik:GridButtonColumn CommandName="Selected" FilterControlAltText="Filter column column"
                                        Text="Edit" UniqueName="column10">
                                    </telerik:GridButtonColumn>
                                    <telerik:GridClientSelectColumn FilterControlAltText="Filter column column" UniqueName="column8">
                                    </telerik:GridClientSelectColumn>
                                    <telerik:GridBoundColumn FilterControlAltText="Filter column1 column" HeaderText="User Name"
                                        UniqueName="column1" DataField="Username">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn FilterControlAltText="Filter column2 column" HeaderText="Email"
                                        UniqueName="column2" DataField="Email" Visible="False">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridDateTimeColumn FilterControlAltText="Filter column3 column" HeaderText="Register Date"
                                        UniqueName="column3" DataField="Regdate_" DataFormatString="{0:dd/MM/yyyy}" Visible="False">
                                    </telerik:GridDateTimeColumn>
                                    <telerik:GridBoundColumn FilterControlAltText="Filter column4 column" HeaderText="First Name"
                                        UniqueName="column4" DataField="Firstname">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn FilterControlAltText="Filter column5 column" HeaderText="Last Name"
                                        UniqueName="column5" DataField="Lastname">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn FilterControlAltText="Filter column7 column" HeaderText="Position"
                                        UniqueName="column7" DataField="ANAL_U0">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn FilterControlAltText="Filter column9 column" HeaderText="Department"
                                        UniqueName="column9" DataField="ANAL_U1">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="ANAL_U2" FilterControlAltText="Filter column column"
                                        HeaderText="Product" UniqueName="column11">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridTemplateColumn DataField="ANAL_U9" FilterControlAltText="Filter column column"
                                        HeaderText="Admin" UniqueName="column6">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="ANAL_U9TextBox" runat="server" Text='<%# Bind("ANAL_U9") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="ANAL_U9Label" runat="server" Enabled="false" Checked='<%# Eval("ANAL_U9").ToString()=="True" %>'>
                                            </asp:CheckBox>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridButtonColumn CommandName="Reset" FilterControlAltText="Filter column column"
                                        HeaderText="Reset Password" Text="Reset" UniqueName="column">
                                    </telerik:GridButtonColumn>
                                    <telerik:GridBoundColumn DataField="ANAL_U8" FilterControlAltText="Filter column12 column"
                                        HeaderText="Is Use" UniqueName="column12">
                                    </telerik:GridBoundColumn>
                                </Columns>
                                <EditFormSettings>
                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                    </EditColumn>
                                </EditFormSettings>
                            </MasterTableView>
                            <ClientSettings AllowDragToGroup="True">
                                <Selecting AllowRowSelect="True" />
                            </ClientSettings>
                            <FilterMenu EnableImageSprites="False">
                            </FilterMenu>
                        </telerik:RadGrid>
                    </div>
                    <br />
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
